<template>
  <div>
    <search-form :listQuery="listQuery" :queryConfig="queryConfig" :labelWidth="100" :search="search" />
    <el-table v-loading="listLoading" :data="list" :default-sort="{prop: 'date', order: 'descending'}" element-loading-text="给我一点时间" border fit
      highlight-current-row>
      <el-table-column align="center" prop="name" label="商品名称"></el-table-column>
      <el-table-column align="center" prop="serialNo" label="商品款号"></el-table-column>
      <el-table-column align="center" prop="skuId" label="SKU编码"></el-table-column>
      <el-table-column align="center" label="SKU">
        <template slot-scope="scope">
          颜色:{{scope.row.erpColorValue}};尺码:{{scope.row.erpSizeValue}}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="remainStock" label="SKU库存"></el-table-column>
    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="listQuery.pageIndex"
      :page-sizes="[10, 20, 50, 100, 200]" :page-size="listQuery.pageSize" background layout="total, sizes, prev, pager, next, jumper"
      :total="listTotal">
    </el-pagination>
  </div>
</template>

<script>
/**
 * 商品库
 */
import mixins from '../../mixins'
import SearchForm from '@/components/searchForm'
import { getSkuStock } from '@/api/goodMiddleStage'
export default {
  name: 'goodsMiddleInventory',
  mixins: [mixins],
  components: {
    SearchForm
  },
  data() {
    return {
      listQuery: {
        goodsName: '',
        pageIndex: 1,
        pageSize: 20,
        queryType: 3,
        serialNo: '',
        skuId: ''
      },
      queryConfig: [
        {
          prop: 'goodsName',
          type: 'input',
          label: '商品名称'
        },
        {
          prop: 'serialNo',
          type: 'input',
          label: '商品款号'
        },
        {
          prop: 'skuId',
          type: 'input',
          label: 'SKU编码'
        }
      ]
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.getList()
    },
    async getList() {
      try {
        const { data } = await getSkuStock(this.listQuery)
        this.list = data.data
        this.listTotal = data.total
      } catch (error) {
        console.log(error)
      }
    }
  }
}
</script>

<style>
</style>
